package com.lukk.TEST;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.lukk.dao.WorkerDAO;

public class test {
	ClassPathXmlApplicationContext ctx;

	@Before
	public void init() {
		ctx = new ClassPathXmlApplicationContext("applicationContext-Controller.xml", "applicationContext.xml");

	}

	@Test
	public void cc() throws Exception {
		DataSource ds = ctx.getBean("dataSource", DataSource.class);
		System.out.println(ds);
		Connection conn = ds.getConnection();
		String sql = "select * from Sample";
		Statement st = conn.createStatement();
		ResultSet rs = st.executeQuery(sql);
		while (rs.next()) {
			System.out.println(rs.getString("type"));
		}
		conn.close();
	}
	
	@Test
	public void test1() {
		WorkerDAO s = ctx.getBean("workerDAO", WorkerDAO.class);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("queryType", 0);
		map.put("queryCode",3149);
		Integer c = s.selectWorkerCountByArea(map);
	
		System.out.println(c);
	}
	
	

}
